#ifndef M_LAMBERTIAN
#define M_LAMBERTIAN
#include"BxDF.h"
class LambertianReflection :public BxDF
{
private:
	Spectrum color;
public:
	LambertianReflection(Spectrum &_color) :BxDF(BxDFType(BSDF_DIFFUSE | BSDF_REFLECTION)) 
	{
		color = _color * InvPi;
	}
	virtual Spectrum f(P3 &light, P3 &view)
	{
		return color;
	}
};

class LambertianTransmission :public BxDF
{
private:
	Spectrum color;
public:
	LambertianTransmission(Spectrum &_color) :BxDF(BxDFType(BSDF_DIFFUSE | BSDF_TRANSMISSION))
	{
		color = _color * InvPi;
	}
	virtual Spectrum f(P3 &light, P3 &view)
	{
		return color;
	}
	virtual P3 ImportanceSample(P3 &light, Float* rands, Float *pdf)
	{
		P3 view = CosineSampleHemisphere(rands);
		if (light.z > 0) view.z *= -1;
		*pdf = getPdf(light, view);
		return view;
	}
	virtual Float getPdf(P3 &light, P3 &view)
	{
		if (light.z*view.z <= 0)
			return abs(view.z)*InvPi;
		return 0; 
	}
};
#endif // !M_LAMBERTIAN

